<html>

<head>
    <meta charset="UTF-8">
    <title>Generate Code</title>
    <script src="vue.global.js"></script>

</head>

<body>
    <div id="summanyPanel" class="container">
        <div class="left-col">
            <div class="title">
                <div>Code</div>
                <div>Generate</div>
            </div>
            <div id="companyList" class="company-list">
                <div v-for="(company, index) in companies" :key="index" :class="{'selected': selectedCompanyIndex === index}"
                    @click="selectCompany(index)" class="company">
                    {{company.name}}
                </div>
            </div>
        </div>
        <div class="right-col">
            <div class="search-bar">
                <div class="input-box">
                    <input type="text" placeholder="Search projects">
                </div>
                <button>New Project</button>
                <button>Import</button>
            </div>
            <div id="projectList" class="project-list">
                <div v-for="(project, index) in projects" :key="index" class="project"
                    @click="clickProject(project.id)">
                    <div class="project-name">{{project.name}}</div>
                    <div class="project-comment">{{project.comment}}</div>
                </div>
            </div>
        </div>
    </div>

    <script>
        const {createApp, ref} = Vue

        // create app
        createApp({
            setup() {
                const companies = ref([{id: 1, name: 'RivTower'}, {id: 2, name: 'Yunus'}, {id: 3, name: 'JiangXi'}])
                const companyProjects = ref(
                    [
                        [
                            {id: 1, name: 'RivDap', comment: 'RivDap MiniProgram'},
                            {id: 2, name: 'AiChat', comment: 'Read stories for Kids'}
                        ],
                        [
                            {id: 3, name: "CodeGenerate", comment: "Generate Code"},
                            {id: 4, name: "VimConfiguration", comment: "Configuration vim"}
                        ],
                        [
                            {id: 5, name: "Logo", comment: "Generate Logo"},
                            {id: 6, name: "GameBar", comment: "A great game bar"}
                        ]
                    ]
                )
                const selectedCompanyIndex = ref(0)
                const projects = ref(companyProjects.value[0])

                function selectCompany(index) {
                    selectedCompanyIndex.value = index
                    projects.value = companyProjects.value[index]
                }

                function clickProject(name) {
                    window.location.href = "/" 
                }

                return {
                    companies,
                    selectedCompanyIndex,
                    selectCompany,
                    projects,
                    clickProject,
                }
            }
        }).mount('#summanyPanel')

    </script>

    <style>
        html,
        body {
            margin: 0;
            padding: 0;
            background-color: #2f3130;
        }

        .container {
            position: fixed;
            display: flex;
            height: 60%;
            width: 40%;
            top: 20%;
            left: 30%;
            background-color: #3c3f41;
            border-radius: 10px;
            color: #bbbbbb;
        }

        .left-col,
        .right-col {
            display: flex;
            flex-direction: column;
            height: 100%;
        }

        .left-col {
            width: 25%;
            margin-right: 10px;
        }

        .right-col {
            width: 75%;
            margin-right: 10px;
        }

        .title {
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            height: 16%;
            width: 100%;
        }

        .title>div {
            font-size: large;
        }

        .company-list {
            display: flex;
            flex-direction: column;
            align-items: center;
            height: 84%;
            width: 100%;
        }

        .company {
            display: flex;
            justify-content: center;
            align-items: center;
            width: 100%;
            height: 8%;
        }

        .company.selected {
            background-color: #4b6eaf;
        }

        .search-bar {
            display: flex;
            align-items: center;
            justify-content: space-between;
            width: 100%;
            height: 10%;
            border-bottom: 1px solid #484b4e;
        }

        .input-box {
            width: 60%;
            margin: 0 5px;
        }

        .input-box>input {
            border: none;
            outline: none;
            color: #787878;
            font-size: 14px;
            background-color: inherit;
            width: 100%;
        }

        .search-bar>button {
            width: 20%;
            background-color: #4c5052;
            border-radius: 5px;
            margin-right: 5px;
            border: 1px solid #5e6060;
            color: inherit;
            height: 40%;
        }

        .project-list {
            display: flex;
            margin-top: 10px;
            flex-direction: column;
            width: 100%;
            height: 100%;
        }

        .project {
            display: flex;
            flex-direction: row;
            align-items: center;
            width: 100%;
            height: 10%;
        }

        .project-name {
            display: flex;
            align-items: center;
            height: 100%;
            margin-left: 10px;
        }

        .project-comment {
            display: flex;
            align-items: center;
            height: 100%;
            margin-left: 10px;
            color: #787878;
            font-size: 14px;
        }

        .project:hover {
            background-color: #464a4d;
        }

    </style>
</body>

</html>
